<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:p="http://primefaces.org/ui">
  
<h:head>
 <title>Página do Atendente</title>
 <script type="text/javascript">
  function startChat()     {
   window.open('batePapo.jsf','atendenteChatWindow', 'width=700,height=500,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
  }
 </script>
</h:head>
  
<h:body>
 <h:form>
  <p:panel header="Login do atendente" rendered="#{not AtendenteMB.autenticado}">
   <h:outputLabel for="nome" value="Login: " />
   <br />
   <h:inputText id="nome" value="#{AtendenteMB.atendente.nome}" />
   <br />
   <h:outputLabel for="senha" value="Senha: " />
   <br />
   <h:inputSecret id="senha" value="#{AtendenteMB.atendente.senha}" />
   <br />
   <h:commandButton action="#{AtendenteMB.login}" value="Logar" />
   <br />
   <h:messages />
  </p:panel>
  
  <p:panel header="Home do atendente" rendered="#{AtendenteMB.autenticado}">
   <h:outputText value="Bem vindo (a), " />
   <strong> <h:outputText value="#{AtendenteMB.atendente.nome}"
      /></strong>!
     
   <h:commandButton action="#{AtendenteMB.logout}" value="Sair" />
   <br />
   <br />
   <p:poll id="myPoll" interval="2" update="pnlDoAttend" />
   <p:outputPanel id="pnlDoAttend">
    <h:outputFormat value="Usuários na fila de espera: {0}">
     <f:param value="#{AtendenteMB.usuariosEspera}" />
    </h:outputFormat>
    <br />
    <br />
    <p:commandButton value="Atender próximo usuário"
       action="#{AtendenteMB.iniciarBatePapo}"
     disabled="#{AtendenteMB.usuariosEspera eq 0}"
     oncomplete="startChat();" />
   </p:outputPanel>
  </p:panel>
 </h:form>
</h:body>
</html>